package com.itheima.a08Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Test3 {
    public static void main(String[] args) {
        //制作点名程序
        //1.创建集合
        ArrayList<String> list1 = new ArrayList<>();
        //2.添加元素
        Collections.addAll(list1, "张三", "李四", "王五", "赵六", "老七", "老八", "山炮", "陈晨", "飞扬", "土豆");
        //3.创建第三个临时集合
        ArrayList<String> list2 = new ArrayList<>();

        //外层表示第几轮点名
        for (int i = 0; i < 10; i++) {
            System.out.println("========" + i + "=================");
            //4.记录集合的长度
            int size = list1.size();

            //生成随机索引
            for (int j = 0; j < size; j++) {
                Random r = new Random();
                int index = r.nextInt(list1.size());
                String name = list1.remove(index);
                list2.add(name);
                System.out.println(name);
            }
            //list1空了
            //list2有10个人的名字
            list1.addAll(list2);
            list2.clear();
        }
    }
}
